<template>
    <el-form>
        <el-form-item label="名称">
            <el-input v-model.trim="user.name" />
        </el-form-item>
        <el-form-item label="性别">
            <el-radio-group v-model="currentUser.sex">
                <el-radio label="unknown">不设置</el-radio>
                <el-radio label="boy">男</el-radio>
                <el-radio label="girl">女</el-radio>
            </el-radio-group>
        </el-form-item>
        <el-form-item label="手机号">
            <p>{{ currentUser.mobile }}</p>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="submit">保存</el-button>
        </el-form-item>
    </el-form>
</template>

<script>
import { mapGetters } from "vuex";
import { get, put, post } from "@/api/request";
export default {
    props: {
        user: {
            type: Object,
            default: () => {
                return {
                    name: "",
                    email: ""
                };
            }
        }
    },
    computed: {
        ...mapGetters(["name", "avatar", "roles", "currentUser"])
    },
    methods: {
        submit() {
            put("user/cu/user/base-update", {
                name: this.currentUser.name,
                sex: this.currentUser.sex,
                id: this.currentUser.id,
            });
            this.$message({
                message: "保存成功",
                type: "success",
                duration: 5 * 1000
            });
        }
    }
};
</script>
